# 发送普通钉钉消息

from dingtalkchatbot.chatbot import DingtalkChatbot


# 发送纯文本
def send_text():
    url = 'https://oapi.dingtalk.com/robot/send?access_token=fe16d4a6014b4141c049870ef96cbb26010b15_testdingding'
    bot = DingtalkChatbot(url,
                          secret='SEC29d0b538722d74b84804a2d387c851035d9a98fc99841e_testdingding')
    bot.send_text('测试一下消息！')
    bot.send_text('测试一下消息！', at_mobiles=['17700000000'])  # 会 @某一个人
    bot.send_text('测试一下消息！', is_at_all=True)  # 会 @所有人


# 发送图片
def send_img():
    url = 'https://oapi.dingtalk.com/robot/send?access_token=fe16d4ac685ecc47ea25ab2ad7f70ef96cbb26010b15_testdingding'
    bot = DingtalkChatbot(url,
                          secret='SEC29d0b538722d74b87c851035d9a98fc99841e_testdingding')
    bot.send_image(pic_url='https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png')


# 发送链接
def send_link():
    url = 'https://oapi.dingtalk.com/robot/send?access_token=fe16049870b914c685ecc47ea25ab2ad7f70ef96cbb26010b15_testdingding'
    bot = DingtalkChatbot(url, secret='SEC29d0b538722d74b84804a2d29ac67d8d387c851035d9a98fc99841e_testdingding')
    bot.send_link(title='百度一下~', text='欢迎欢迎！！！', message_url='http://www.baidu.com',
                  pic_url='https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png')


# 发送富文本
def send_md():
    url = 'https://oapi.dingtalk.com/robot/send?access_token=fe161c049870b914c685ecc47ea25ab2ad7f70ef96cbb26010b15_testdingding'
    bot = DingtalkChatbot(url, secret='SEC29d0b538722d74b84804a2d9ac67d8d387c851035d9a98fc99841e_testdingding')
    bot.send_markdown(title='富文本-百度一下~', text='## 欢迎使用百度搜索！！！\n'
                                                     '百度搜索好啊!!<br/>'
                                                     '百度搜索秒啊!!'
                                                     '![BaiDu](https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png)'
                      )


if __name__ == '__main__':
    # send_text()
    # send_img()
    # send_link()
    send_md()
